home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.Menu;
- import java.awt.MenuItem;
- import java.awt.PopupMenu;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.text.DateFormat;
- import java.util.EventObject;
-
- public class MenuPopUp extends Applet implements MouseListener, ActionListener {
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private PopupMenu pop;
- private String statusBarText;
- private AudioClip sound;
- private AudioClip clicSound;
- private boolean loopSound;
- private Color backColor;
- private Color enterBackColor;
- private String mode = "enter";
- private Image backImage;
- private String backImageName;
- private boolean loaded = false;
- private boolean isBackImage = false;
- private boolean paintable = false;
- // $FF: renamed from: b java.awt.Graphics
- private Graphics field_2;
- private Image buffer;
- private int decy;
- private int decx;
- private int wiBack;
- private int heBack;
- private int text_height;
- private int string_width;
- private Color textColor;
- private String text;
- // $FF: renamed from: df java.text.DateFormat
- private DateFormat field_3;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_4;
- private boolean isText = false;
- private String location;
-
- public String getAppletInfo() {
- return "Name: MenuPopUp\r\nAuthor: Taiji Software\r\n";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- this.stop();
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var11) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- this.pop = new PopupMenu();
- this.giveMenu("");
- ((Component)this).add(this.pop);
- if (this.isBackImage) {
- MediaTracker tracker = new MediaTracker(this);
- this.backImage = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.backImageName);
- tracker.addImage(this.backImage, 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- this.paintable = !tracker.isErrorAny();
- } catch (InterruptedException var10) {
- this.stop();
- }
-
- if (!this.loaded) {
- this.stop();
- return;
- }
-
- this.wiBack = this.backImage.getWidth(this);
- this.heBack = this.backImage.getHeight(this);
- }
-
- this.buffer = ((Component)this).createImage(this.field_0, this.field_1);
- this.field_2 = this.buffer.getGraphics();
-
- try {
- Font f = new Font("TimesRoman", 1, this.text_height);
- this.field_2.setFont(f);
- } catch (Exception var9) {
- Font f = this.field_2.getFont();
- this.field_2.setFont(new Font(f.getName(), f.getStyle(), this.text_height));
- }
-
- if (this.isText) {
- this.field_4 = this.field_2.getFontMetrics();
- this.string_width = this.field_4.stringWidth(this.text);
- if (this.decx == 0) {
- this.decx = (this.field_0 - this.string_width) / 2;
- }
-
- if (this.decy == 0) {
- this.decy = (this.field_1 + this.field_4.getMaxAscent() - this.field_4.getMaxDescent()) / 2 - this.text_height;
- }
-
- this.field_2.setColor(this.textColor);
- }
-
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- } else {
- this.sound.play();
- }
- }
-
- this.paintable = true;
- ((Component)this).repaint();
- }
-
- public Menu giveMenu(String prof) {
- Menu menu = new Menu(((Applet)this).getParameter("text" + prof));
- int i = 0;
-
- while(true) {
- ++i;
- String prof2 = prof + "#" + Integer.toString(i);
- if (((Applet)this).getParameter("text" + prof2) == null) {
- return menu;
- }
-
- String s = ((Applet)this).getParameter("text" + prof2 + "#1");
- if (s == null) {
- s = ((Applet)this).getParameter("text" + prof2);
- if (s.equals("-")) {
- if (prof.equals("")) {
- this.pop.addSeparator();
- } else {
- menu.addSeparator();
- }
- } else {
- MenuItem menuitem = new MenuItem(((Applet)this).getParameter("text" + prof2));
- menuitem.addActionListener(this);
- menuitem.setActionCommand(((Applet)this).getParameter("link" + prof2));
- if (prof.equals("")) {
- this.pop.add(menuitem);
- } else {
- menu.add(menuitem);
- }
- }
- } else if (prof.equals("")) {
- this.pop.add(this.giveMenu(prof2));
- } else {
- menu.add(this.giveMenu(prof2));
- }
- }
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.mode = ((Applet)this).getParameter("mode");
- this.location = ((Applet)this).getParameter("location");
- this.backColor = this.getColor("background_color");
- ((Component)this).setBackground(this.backColor);
- this.enterBackColor = this.getColor("enter_background_color");
- this.textColor = this.getColor("text_color");
- this.text = ((Applet)this).getParameter("text");
- if (this.text != null) {
- this.isText = true;
- }
-
- String s = ((Applet)this).getParameter("text_height");
- if (s != null) {
- this.text_height = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("height_shift");
- if (s != null) {
- this.decy = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("width_shift");
- if (s != null) {
- this.decx = Integer.parseInt(s);
- }
-
- this.backImageName = ((Applet)this).getParameter("background_image");
- if (this.backImageName != null) {
- this.isBackImage = true;
- }
-
- this.statusBarText = ((Applet)this).getParameter("status_bar_text");
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- } else {
- this.loopSound = false;
- }
- }
-
- s = ((Applet)this).getParameter("clic_sound_name");
- if (s != null) {
- this.clicSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public final void paint(Graphics g) {
- if (this.paintable) {
- this.field_2.clearRect(0, 0, this.field_0, this.field_1);
- if (this.isBackImage & this.loaded) {
- this.field_2.drawImage(this.backImage, (this.field_0 - this.wiBack) / 2, (this.field_1 - this.heBack) / 2, this);
- }
-
- if (this.isText) {
- this.field_2.drawString(this.text, this.decx, this.text_height + this.decy);
- }
-
- g.drawImage(this.buffer, 0, 0, this);
- }
-
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- public void showPopup(int x, int y) {
- if (this.location.equals("mouse")) {
- this.pop.show(this, x, y);
- } else if (this.location.equals("center")) {
- this.pop.show(this, this.field_0 / 2, this.field_1 / 2);
- } else {
- if (this.location.equals("random")) {
- this.pop.show(this, (int)((double)this.field_0 * Math.random()), (int)((double)this.field_1 * Math.random()));
- }
-
- }
- }
-
- public void actionPerformed(ActionEvent event) {
- if (((EventObject)event).getSource() instanceof MenuItem) {
- if (this.clicSound != null) {
- this.clicSound.play();
- }
-
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(((MenuItem)((EventObject)event).getSource()).getActionCommand());
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void stop() {
- if (this.sound != null) {
- this.sound.stop();
- }
-
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public MenuPopUp() {
- this.mode = "enter";
- this.location = "mouse";
- this.textColor = Color.black;
- this.text_height = 10;
- this.decx = 0;
- this.decy = 0;
- ((Component)this).addMouseListener(this);
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- if (this.enterBackColor != null) {
- ((Component)this).setBackground(this.enterBackColor);
- ((Component)this).repaint();
- }
-
- if (this.mode.equals("enter")) {
- this.showPopup(e.getX(), e.getY());
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- if (this.enterBackColor != null) {
- ((Component)this).setBackground(this.backColor);
- ((Component)this).repaint();
- }
-
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.mode.equals("clic")) {
- this.showPopup(e.getX(), e.getY());
- }
-
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-